home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / Sherlock 2.0 / DevLibSrc / Main_DevLib / LIBio.h < prev    next >
Text File  |  1994-07-11  |  3KB  |  94 lines

  1. /*
  2.     devlib: header file for LIBio.c.
  3.     
  4.     source:  LIBio.h
  5.     started: December 13, 1993.
  6.     version:
  7.         July 11, 1994.
  8.             Added io_remove, io_rename, io_seek and io_write_buffer.
  9.         May 23, 1994.
  10.             Added text_flag to io_open, io_create, io_read_all and io_read_pad_all.
  11.         January 9, 1994.
  12.             Added io_read_pad_all.
  13. */
  14.  
  15. #ifndef LIBio_h_
  16. #define LIBio_h_
  17.  
  18. #pragma once
  19.  
  20.     /* Constants. */
  21.     
  22. #define IO_EOF_CHAR 0x01
  23.  
  24.     /* Structures and typedefs. */
  25.     
  26. #ifndef LIB_IO_TYPEDEFS
  27.     #define LIB_IO_TYPEDEFS
  28.     typedef struct io_mem_struct        io_mem_block;
  29.     typedef struct io_file_struct        io_file;
  30.     typedef struct io_path_list_struct    io_path_list;
  31. #endif
  32.  
  33. struct io_mem_struct {
  34.     char *    mem_start;        /* Logical start of buffer. */
  35.     long    mem_length;        /* Logical length of buffer. */
  36.     char *    mem_freep;        /* Use this to free the memory! */
  37. };
  38.  
  39. struct io_file_struct {
  40.     TYPE_LIST(io_file);
  41.     int            io_file_status;        /* Status of file. */
  42.     char *        io_file_path_name;    /* File path name. */
  43.     FILE *        io_file_file;        /* OS file info: used only in ANSI_io.c. */
  44.     int            io_file_handle;        /* file handle: used only in io.c. */
  45.     char *        io_file_buffer;        /* File buffer. */
  46.     char *        io_file_pointer;    /* Pointer to first free char in buffer. */
  47.     long        io_file_bufsize;    /* Size of the file buffer. */
  48.     long        io_file_count;        /* Number of characters in the buffer. */
  49. };
  50.  
  51. struct io_path_list_struct {
  52.     TYPE_LIST(io_path_list);
  53.     char * io_path_name;
  54. };
  55.  
  56.     /* Prototypes. */
  57.  
  58.     /* Synonyms for cant_flag. */
  59.     enum { CANT_MESSAGE    = TRUE, NO_CANT_MESSAGE = FALSE };
  60.     
  61.     /* Synonyms for text_flag. */
  62.     enum { IO_TEXT_FILE = TRUE, IO_BINARY_FILE = FALSE };
  63.     
  64.     /* Synonyms for return from io_seek. */
  65.     #define IO_SEEK_OK 0
  66.  
  67. void        io_close            (io_file * file);
  68. void        io_close_all        (void);
  69. io_file *    io_create            (char * path_name, bool cant_flag, bool text_flag);
  70. bool        io_is_open            (io_file * file);
  71. long        io_length            (io_file * file);
  72. io_file *    io_open                (char * path_name, bool cant_flag, bool text_flag);
  73. int            io_physical_newline    (void);
  74. long        io_read                (io_file * file, void * buffer, long n);
  75. io_mem_block * io_read_all        (char * path_name, bool cant_flag, bool text_flag);
  76. io_mem_block * io_read_pad_all
  77.     (char * path_name, int lead_pad, char lead_char, int trail_pad, char trail_char,
  78.     bool cant_flag, bool text_flag);
  79. void        io_remove            (char * path_name);
  80. void        io_rename            (char * old_name, char * new_name);
  81. int            io_seek                (io_file * file, long offset);
  82. void        io_show_file        (io_file * file);
  83. long        io_write            (io_file * file);
  84. long        io_write_buffer        (io_file * file, void * buffer, long n);
  85.  
  86.     /* Global statistics variables. */
  87.  
  88. extern long    io_read_chars;    /* Chars read by io_read and io_read_all. */
  89. extern long    io_write_chars;    /* Chars written by io_write. */
  90. extern long    io_nl_count;    /* Number of consecutive newlines output. */
  91. extern long io_line_count;    /* Number of chars in current output line. */
  92.  
  93. #endif /* LIBio_h_ */
  94.